package com.edu.exam.entity.examination.paper.technical;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import jakarta.persistence.*;
import java.time.LocalDateTime;

// 导入外部枚举类
import com.edu.exam.enums.examination.paper.OmrQuestionType;
import com.edu.exam.enums.examination.paper.OmrAnswerStatus;

/**
 * OMR答案详情实体类
 *
 * 根据E-04-01设备适配子模块数据库设计实现
 * 存储每个客观题的详细识别结果。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class OmrAnswerDetail {

    /**
     * 详情ID，主键
     */
    @Id
    @Column(name = "detail_id", length = 64)
    private String detailId;

    /**
     * OMR结果ID（外键）
     */
    @Column(name = "omr_result_id", length = 64, nullable = false)
    private String omrResultId;

    /**
     * 识别结果ID（外键）
     */
    @Column(name = "recognition_result_id", length = 64, nullable = false)
    private String recognitionResultId;

    /**
     * 考试ID
     */
    @Column(name = "exam_id", length = 64, nullable = false)
    private String examId;

    /**
     * 题目编号
     */
    @Column(name = "question_id", nullable = false)
    private Integer questionId;

    /**
     * 题目类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "question_type", length = 32, nullable = false)
    private OmrQuestionType questionType;

    /**
     * 正确答案
     */
    @Column(name = "correct_answer", length = 8)
    private String correctAnswer;

    /**
     * 识别出的答案
     */
    @Column(name = "recognized_answer", length = 8)
    private String recognizedAnswer;

    /**
     * 气泡强度
     */
    @Column(name = "bubble_intensity", precision = 5, scale = 2)
    private Double bubbleIntensity;

    /**
     * 置信度分数
     */
    @Column(name = "confidence_score", precision = 5, scale = 2)
    private Double confidenceScore;

    /**
     * 是否多选题
     */
    @Column(name = "is_multiple")
    private Boolean isMultiple;

    /**
     * 异常类型
     */
    @Column(name = "anomaly_type", length = 32)
    private String anomalyType;

    /**
     * 处理时间（毫秒）
     */
    @Column(name = "processing_time")
    private Long processingTime;

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

    /**
     * 版本号（用于乐观锁）
     */
    @Version
    @Column(name = "version", nullable = false)
    private Integer version = 0;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;

}